    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <h1 id="main"> Jquery </h1> 
        <h1 price="900"> hello world </h1>

    </body>
    <script>
    //$("#main").html("内容");

    (function(){
        var jquery = window.$ = function(xzq){
            return new jquery.prototype.init(xzq);
        }

        jquery.prototype = {
            init:function(xzq){
                let arr = document.querySelectorAll(xzq);
                Array.prototype.push.apply( this ,arr);
                return this;
            },
            html:function(v){
                if(v==undefined){
                    return this[0].innerHTML;
                }
                for(let i =0; i<this.length;i++){
                    this[i].innerHTML = v;
                }
            },
            css:function(attr,val){
                if(val==undefined){  //空
                    return this[0].style[attr];
                }
                for(var i=0;i<this.length;i++){
                    this[i].style[attr] = val;
                }
                //实现链式
                return this;  
            },
            eq:function(){},
            attr:function(){},
            each:function(){}
        }
        //允许其他人给框架加功能
        jquery.extends= function(obj){
            for(var attr in obj){
                this[attr]= obj[attr];
            }
        }

        //把方法挂载
        jquery.prototype.init.prototype = jquery.prototype;
        
    })();


    //扩展功能
    $.extends({
        trim:function(str){
            return str.replace(/^\s+|\s+$/g,'');
        }
    });

    let t  = '   hello   world     ';
    console.log( t );
    console.log(  $.trim(t) );


    // console.log( $('h1') ) ;
    // console.log( $('h1').html() );
    // //$("#main").html('你好世界');
    // $('h1').css('background-color','pink')
    //        .css('border','10px solid blue')

    </script>
    </html>